package com.zztt.logmask.common;

import com.zztt.logmask.common.factory.DefaultMaskHandleFactory;
import com.zztt.logmask.common.handle.MaskHandle;
import com.zztt.logmask.common.matcher.DefautltMaskHandlesMatcher;
import com.zztt.logmask.common.matcher.MaskHandlesMatcher;

import java.util.List;

/**
 * 掩码处理的代理类
 */
public class MaskHandleDelegate {
    /**
     * 掩码处理匹配器
     */
    private static final MaskHandlesMatcher MASK_HANDLES_MATCHER = new DefautltMaskHandlesMatcher(DefaultMaskHandleFactory.getInstance().getAllMaskHandle());

    /**
     * 开启掩码处理功能
     * @param str
     */
    public void mask(StringBuilder str) {
        List<MaskHandle> maskHandleList = MASK_HANDLES_MATCHER.matcher(str);
        for (MaskHandle maskHandle : maskHandleList) {
            maskHandle.mask(str);
        }
    }
}
